{% extends "master.html" %}

{% block title %}Ном оруулах{% endblock %}

{% block script %}
<script type="text/javascript">
function saveBook()
{
	document.forms['save_book'].submit();
}
</script>
{% endblock %}

{% block content %}
	{% if user %}
		{% if author_list %}
			<form name="save_book" method="POST" enctype="multipart/form-data">
				<table align="center">
					<tbody>
						<tr>
							<td colspan="2"><center><strong><p>Ном оруулах</p></strong></center></td>
						</tr>
						<tr>
							<td>Номын файл: </td>
							<td><input type="file" name="file" /></td>
						</tr>
						<tr>
							<td></td>
							<td>1MB-аас хэтрэхгүй файл оруулна уу.</td>
						</tr>
						<tr>
							<td>Сэдэв: </td>
							<td><input type="text" name="title" value="{{ chosen_book.title }}" /></td>
						</tr>
						<tr>
							<td>ISBN: </td>
							<td><input type="text" name="isbn" value="{{ chosen_book.isbn }}" /></td>
						</tr>
						<tr>
							<td>Номын төрөл: </td>
							<td>
								<select name="name">
									<option></option>
									{% for name in name_list %}
											<option>{{ name.name }}</option>
									{% endfor %}
								</select>
							</td>
						</tr>
						<tr>
							<td>Бичигдсэн хэл: </td>
							<td>
								<select name="language">
									<option></option>
									{% for language in language_list %}
										{% ifequal chosen_book.language language %}
											<option selected>{{ language }}</option>
										{% else %}
											<option>{{ language }}</option>
										{% endifequal %}
									{% endfor %}
								</select>
							</td>
						</tr>
						<tr>
							<td>Агуулга: </td>
							<td><textarea name="content">{{ chosen_book.content }}</textarea></td>
						</tr>
						<tr>
							<td>Бичигдсэн он: </td>
							<td><input type="text" name="year" value="{{ chosen_book.year }}" /></td>
						</tr>
						<tr>
							<td>Үнэ: </td>
							<td>
								<input type="text" name="price" value="{{ chosen_book.price }}" />
								<select name="currency">
									<option></option>
									{% for currency in currency_list %}
										{% ifequal chosen_book.currency currency %}
											<option selected>{{ currency }}</option>
										{% else %}
											<option>{{ currency }}</option>
										{% endifequal %}
									{% endfor %}
								</select>
							</td>
						</tr>
						<tr>
							<td>Нийт хуудсын тоо: </td>
							<td><input type="text" name="total_pages" value="{{ chosen_book.total_pages }}" /></td>
						</tr>
						<tr>
							<td></td>
							<td>
								<input type="button" value="Хадгалах" onclick="saveBook()" />
								<input type="button" value="Буцах" onclick="history.go(-1)" />
								<input type="hidden" name="chosen_book" value="{{ chosen_book.key.id }}" />
							</td>
						</tr>
					</tbody>
				</table>
			</form>
		{% endif %}
	{% endif %}
{% endblock %}

{% block sidebar %}{% include "sidebar.html" %}{% endblock %}